package org.ben.xintoucloud.javase.oopstudent;

/**
 * @Author: Ben
 * @Date: 2019/7/10 14:56
 */
public class Student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length()>=5){
            System.out.println("对不起，您输入的姓名长度超过了5位，请重新输入");
        }else {
            this.name = name;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age<=6){
            System.out.println("对不起，您输入的年龄小于6岁");
            this.age = 6;
        }else {
            this.age = age;
        }
    }
    public void say(){
        System.out.println("我叫"+name+"我今年"+age+"岁");
    }
}
